<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>书海拾贝(我的借阅)</title>
  <link rel="stylesheet" href="css/base.css">
  <link rel="stylesheet" href="css/my.css">
  <link rel="stylesheet" href="css/dropload.css">
  <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1, user-scalable=no">
</head>
<body>
<div class="header-box">
  <p>书海拾贝</p>
</div>
<div class="borrow">
  <div class="borrow_top" id="borrow_top">
    <a href="javascript:;" class="borr_active" onclick="load(null)">全部(<h id="countAll">0</h>)</a>
    <a href="javascript:;" onclick="load(8)" id="a8">智商(<h id="count8">0</h>)</a>
    <a href="javascript:;" onclick="load(10)" id="a10">情商(<h id="count10">0</h>)</a>
    <a href="javascript:;" onclick="load(6)" id="a6">心商(<h id="count6">0</h>)</a>
    <a href="javascript:;" onclick="load(12)" id="a12">逆商(<h id="count12">0</h>)</a>
    <a href="javascript:;" onclick="load(7)" id="a7">美商(<h id="count7">0</h>)</a>
    <a href="javascript:;" onclick="load(9)" id="a9">财商(<h id="count9">0</h>)</a>
    <a href="javascript:;" onclick="load(13)" id="a13">亲子(<h id="count13">0</h>)</a>
    <a href="javascript:;" onclick="load(15)" id="a15">育儿(<h id="count15">0</h>)</a>
  </div>
  <div class="huise3"></div>
  <div class="borrow_text">
    <p>
      <img src="img/my/tuceng 16@2x.png">
      <span>科学育儿</span>
      <a href="javascript:;">更多 ></a>
    </p>
    <div class="borrow_text_bott">
      <img src="img/my/tuceng 17@2x.png">
      <div class="borrow_text_bott_right">
        <p>如何培养下一个莫扎特？</p>
        <p>莫扎特是世界音乐史上少有的天才人物，他4岁谱曲，6<br>岁的莫扎特在父亲的带领下到慕尼黑、维也纳、普雷斯 </p>
      </div>
    </div>
  </div>
  <div class="huise3"></div>
  <div class="borrow_list">
    <ul id="borrow_list_box">
      <li>
<!--         <img src="img/index/tuceng 32@2x.png"> -->
<!--         <div class="box_right"> -->
<!--           <p> 牙虫大搬家 </p> -->
<!--           <p>(日)西本康子</p> -->
<!--           <p class="daoqi">到期:<i>2018-06-01</i></p> -->
<!--           <div class="comment"> -->
<!--             <a href="damageReport.html?id=12&tp=0">损坏上报</a> -->
<!--             <a href="damageReport.html?id=36&tp=1">评价</a> -->
<!--           </div> -->
<!--           <p style="display:none;" class="isshow_p p22"><img src="img/my/tuceng 19@2x.png"></p> -->
<!--           <p style="display:none;" class="isshow_p"><img src="img/my/tuceng 18@2x.png"></p> -->
<!--         </div> -->
<!--       </li> -->
<!--       <li> -->
<!--         <img src="img/index/tuceng 30@2x.png"> -->
<!--         <div class="box_right"> -->
<!--           <p> 鸭子骑车记 </p> -->
<!--           <p>(美)大卫·香农</p> -->
<!--           <p class="daoqi">到期:<i>2018-06-01</i></p> -->
<!--           <div class="comment"> -->
<!--             <a href="damageReport.html?id=78&tp=0">损坏上报</a> -->
<!--             <a href="damageReport.html?id=45&tp=1">评价</a> -->
<!--           </div> -->
<!--           <p style="display:none;" class="isshow_p p22"><img src="img/my/tuceng 19@2x.png"></p> -->
<!--           <p style="display:none;" class="isshow_p"><img src="img/my/tuceng 18@2x.png"></p> -->
<!--         </div> -->
<!--       </li> -->
<!--       <li> -->
<!--         <img src="img/index/tuceng 31@2x.png"> -->
<!--         <div class="box_right"> -->
<!--           <p> 胆小鬼威利 </p> -->
<!--           <p>(英)安东尼·布朗</p> -->
<!--           <p class="daoqi" style="display:none;">到期:<i>2018-06-01</i></p> -->
<!--           <div class="comment" style="display:none;"> -->
<!--             <a href="damageReport.html?id=51&tp=0">损坏上报</a> -->
<!--             <a href="damageReport.html?id=11&tp=1">评价</a> -->
<!--           </div> -->
<!--           <p style="display:block;" class="isshow_p p22"><img src="img/my/tuceng 19@2x.png"></p> -->
<!--           <p style="display:block;" class="isshow_p"><img src="img/my/tuceng 18@2x.png"></p> -->
<!--         </div> -->
      </li>
    </ul>
  </div>
</div>
<div class="footer_kb"></div>
<div class="footer_kb1"></div>
</body>
<script id="book_show_tmpl" type="text/x-jsrender">
{{if #data.book != null}}
<li id="{{:id}}" >
<b></b>
<input class="stockId" type="hidden" value="{{:bid}}">
         <div class="divImg"><img src="{{:#data.book.bookImage1}}"></div>
		<div class="box_right">
		<p class="bookName">
		{{:#data.book.bookName}}</p>
		<p>作者：{{:#data.book.author}}</p>
		<p>主题：<i>{{:#data.book.classificationName}}</i></p>
		{{if state == 1}}
          <p class="daoqi">到期：<i>{{:borrowEndTime}}</i></p>
          <p class="didian">借阅点：<i>{{:borrowPName}}</i></p>
          <div class="comment">
            <a href="damageReport.html?id=21&tp=0">损坏上报</a>
            <a href="damageReport.html?id=12&tp=1">评价</a>
          </div>
		{{/if}}
		{{if state != 1}}
			<p style="display:block;" class="isshow_p p22"><img src="img/my/tuceng 19@2x.png"></p>
          	<!--<p style="display:block;" class="isshow_p"><img src="img/my/tuceng 18@2x.png"></p>-->
		{{/if}}

        </div>
      </li>
{{/if}}
</script>
<script src="js/jquery.js"></script><script src="js/jquery.cookie.js"></script>
<script src="js/base.js?v=base.js?v=20180102"></script>
<script src="js/jsrender.js"></script>
<script src="js/dropload.min.js"></script>
<script>
var pageNum = 1;
var pageSize = 5;

  $("#borrow_top>a").click(function () {
      $(this).addClass('borr_active').siblings().removeClass('borr_active');
  });
  
function load(type){
	pageNum = 1;
	$("#borrow_list_box").empty();
	loadData(type);
}  
  
loadType();
loadData();
function loadType(){
	var userId = getUserId();
		$.get({
			url : window.baseUrl + "/api/book/borrowReturnLog/bookCountByType",
			data : {
				uid : userId
			},
			success : function(data) {
				var data = data.data;
				var countAll = 0;
				$.each(data,function(key,value){
					debugger
					var cid = value.book.cid;
					var count = value.count;
					countAll += count
					$("#count"+cid).text(count);
				})
				$("#countAll").text(countAll);
			}
		});
}  

function loadData(type){
	var userId = getUserId();
	$.get({
		url : window.baseUrl + "/api/book/borrowReturnLog/findPage",
		data : {
			uid : userId,
			bookCid : type,
			"pageNum" : pageNum,
			"pageSize" : pageSize
		},
		success : function(data) {
			var data = data.data.list;
			//$("#borrow_list_box").empty();
			var htmlOutput = $.templates("#book_show_tmpl").render(data);
			$("#borrow_list_box").append(htmlOutput);
		}
	});
}
  

var dropload = $('.borrow_list').dropload({
	domDown : {
        domClass   : 'dropload-down',
        domRefresh : '<div class="dropload-refresh">下面暂无数据</div>',
    },
    scrollArea : window,
    autoLoad: false,
    loadDownFn : function(me){
    	 pageNum+=1;
    	 loadData();
    	 me.resetload();
    }
});	
</script>
</html>